// src/utils/print.js
import printJS from 'print-js';

export function printContent(contentId, options = {}) {
  const defaultOptions = {
    printable: contentId,
    type: 'html',
    targetStyles: ['*'],
    style: `
      @media print {
        body * {
          visibility: hidden;
        }
        #printJS-form, #printJS-form * {
          visibility: visible;
        }
        #printJS-form {
          position: absolute;
          left: 0;
          top: 0;
          width: 100%;
          margin: 0;
        }
        .el-dialog__header, .el-dialog__footer {
          display: none;
        }
        .el-descriptions {
          width: 100%;
        }
        .el-descriptions-item {
          margin-bottom: 5px;
        }
        .el-descriptions-item__label {
          font-weight: bold;
        }
        .el-descriptions-item__content {
          margin-left: 5px;
        }
      }
    `
  };

  const finalOptions = { ...defaultOptions, ...options };

  printJS(finalOptions);
}